<?php
namespace app\admin\controller;
use think\Controller;
use think\Db;
use think\Request;

class Image extends Base {
    function image_list(){
        $image_list=Db::name('image')->select();
        $this->assign('image_list',$image_list);
        return $this->fetch('image_list');
    }
    function image_post(){
        return view('image_post');
    }
    function delete(){
        $id=input('get.id');
        Db::name('image')->where('id',$id)->delete();
        return $this->success('删除成功！');
    }
    function upload(){
        $request=Request::instance();
        $file=$request->file('file');
        $info=$file->move(ROOT_PATH.'public'.DS.'upload'.DS.'head');
        $src="/public/upload/head/".$info->getSaveName();
        Db::name('image')->insert(['imgsrc'=>$src]);
    }
}